function borderBottomSlide(ele)
{
	$(ele).addClass("slide-class");
//	$(ele).next().css("z-index",100000);
	$(ele).find("i").removeClass("icon-caret-down").addClass("icon-caret-up");
}
function borderBottomShow(ele)
{
	$(ele).removeClass("slide-class");
	$(ele).find("i").removeClass("icon-caret-up").addClass("icon-caret-down");
}

//$"#carousel-box"
var carouselBoxHeight = $("#big-carousel-box").height();
var carouselBoxWidth = $("#big-carousel-box").width();
myCarousel("big-carousel-box",carouselBoxHeight,carouselBoxWidth,"big-white-pointer-control");


//office-stationery
var officeStaHeight = $("#office-stationery").height();
var officeStaWidth = $("#office-stationery").width();
myCarousel("office-stationery",officeStaHeight,officeStaWidth,"white-pointer-control");

//labor-insurance-supplies
var laborInsHeight = $("#labor-insurance-supplies").height();
var laborInsWidth = $("#labor-insurance-supplies").width();
myCarousel("labor-insurance-supplies",laborInsHeight,laborInsWidth,"white-pointer-control");

/*office-consumables*/
var officeConHeight = $("#office-consumables").height();
var officeConWidth = $("#office-consumables").width();
myCarousel("office-consumables",officeConHeight,officeConWidth,"white-pointer-control");

//office-equipment
var officeEquHeight = $("#office-equipment").height();
var officeEquWidth = $("#office-equipment").width();
myCarousel("office-equipment",officeEquHeight,officeEquWidth,"white-pointer-control")

$(".yours").on("mouseover",function(e)
{
	$(this).next().css("display","block");
	borderBottomSlide(this);
});
$(".yours").on("mouseout",function()
{
	$(this).next().css("display","none");
	borderBottomShow(this);
});
$(".list-box").on("mouseover",function()
{
	$(this).css("display","block");
	borderBottomSlide($(this).prev());
});
$(".list-box").on("mouseout",function()
{
	$(this).css("display","none");
	borderBottomShow($(this).prev());
});

//window.onresize = function()
//{
//	var screenWidth = document.body.clientWidth;
//	$("body").css({"width":"$(window).width()","overflow-x":"hidden"});  
//}

$("#shopping-list-box>ul>li").on("mouseover",function()
{			
	$("#nav-shop-list").removeClass("nav-shop-list-fade");
	switch($(this).attr("num"))
	{
		case "1":
			$("#nav-shop-list>ul").css("display","none");
			$("#ul-first").css("display","block")
			break;
		case "2":
			$("#nav-shop-list>ul").css("display","none");
			$("#ul-second").css("display","block")
			break;
		case "3":
			$("#nav-shop-list>ul").css("display","none");
			$("#ul-third").css("display","block")
			break;
		case "4":
			$("#nav-shop-list>ul").css("display","none");
			$("#ul-fourth").css("display","block")
			break;
		default:
			break;
	}
});
$("#shopping-list-box>ul>li").on("mouseout",function()
{
	$("#nav-shop-list").toggleClass("nav-shop-list-fade");
})

$("#nav-shop-list").on("mouseover",function()
{
	$("#nav-shop-list").toggleClass("nav-shop-list-fade");
});
$("#nav-shop-list").on("mouseout",function()
{
	$("#nav-shop-list").toggleClass("nav-shop-list-fade");
});

console.log($.cookie().username);

if($.cookie().username)
{
	$(".welcomeToMarket").html("您好");
	$(".name").css("display","inline-block");
	$(".person").css("display","inline-block");
	$(".name").html($.cookie().username);
	$(".person").html("[个人]");
	$("#greed").addClass("greed");
	$("#greed").html("v0");
	$(".logout").html("[&emsp;退出&emsp;]");
	
	$("#greed").click(function(e)
	{
		e.preventDefault();
	});
	$(".logout").on("click",function(e)
	{
		$("#greed").removeClass("greed");
		e.preventDefault();
		alert("点击了");
		$.removeCookie("username");
		location.href = "/";
	});
};



$(".singal-goods>a:nth-of-type(1)").click(function(e){
	e.preventDefault();
	var pic = $(e.target).attr("src");
	var goodsName = "A4全木浆复印纸";
	var price = $(this).siblings(".price").children("b").html();
	var userId = JSON.parse($.cookie().userID.split(":")[1]);
	$.cookie("userId",userId);
	console.log(userId);
	
	goodsData = {
		userId:userId,
		goodsPic:pic,
		goodsName:goodsName,
		goodsPrice:price
	}
	console.log(goodsData);
	var str = JSON.stringify(goodsData);
	$.cookie("gData",str);
//	console.log($.cookie().gData);
	location.href = "tradeDetail.html";

});


